package meijuli.com.join51.business.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.bumptech.glide.Glide;
import meijuli.com.join51.business.R;

/**
 *
 *
 * @author wenqin 2017-04-24 16:57
 */

public class PictureDetailActivity extends BaseActivity implements View.OnClickListener{
    public static final String KEY_PIC_PATH = "picPath";
    ImageView mPic;
    LinearLayout mPicLayout;

    public static void start(Activity activity, String picPath) {
        Intent intent = new Intent(activity, PictureDetailActivity.class);
        intent.putExtra(KEY_PIC_PATH, picPath);
        activity.startActivity(intent);
    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_picture_detail);
        mPic = findViewById(R.id.pic);
        mPicLayout = findViewById(R.id.pic_layout);
        Glide.with(this).load(getIntent().getStringExtra(KEY_PIC_PATH))
                .error(R.mipmap.img_default)
                .into(mPic);
        mPic.setOnClickListener(this);
        mPicLayout.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.pic:
            case R.id.pic_layout:
                finish();
                break;
            default:

                break;
        }
    }
}
